/**
 * Created by meiguizhinian on 2018/7/6
 * Copyright © 2018 lixiaolong. All rights reserved.
 */

//TODO：等待完成
cc.ttfConfig = function (filePath="", size=12, glyphCollection=cc.GlyphCollection.DYNAMIC,
                         customGlyphCollection=null, useDistanceField=false, outline=0,
                         useItalics=false, useBold=false, useUnderline=false, useStrikethrough=false) {
	let config = {};
	//成员变量
	config.fontFilePath = filePath;
	config.fontSize = size;

	config.glyphs = glyphCollection;
	config.customGlyphs = customGlyphCollection;

	config.distanceFieldEnabled = useDistanceField;
	config.outlineSize = outline;

	config.italics = useItalics;
	config.bold = useBold;
	config.underline = useUnderline;
	config.strikethrough = useStrikethrough;

	if (outline>0) {
		config.distanceFieldEnabled = false;
	}

	return config;
};

//html5 版本没有 cc.Label,目前使用 cc.LabelTTF 创建，下面是兼容接口
if (!cc.Label) {
	//*
	cc.Label = {
		createWithSystemFont : function (text, fontName, fontSize, dimensions=undefined, hAlignment=undefined, vAlignment=undefined) {
			fontName = LLFont.getFontNameWithFilepath(fontName);
			return new cc.LabelTTF(text, fontName, fontSize, dimensions, hAlignment, vAlignment);
		},
		createWithTTF : function() {
			if (cc.isString(arguments[0])) {
				return this._createWithTTFText.apply(this, arguments);
			} else {
				return this._createWithTTFConfig.apply(this, arguments);
			}
		},
		_createWithTTFText : function (text, fontName, fontSize, dimensions=undefined, hAlignment=undefined, vAlignment=undefined) {
			fontName = LLFont.getFontNameWithFilepath(fontName);
			return new cc.LabelTTF(text, fontName, fontSize, dimensions, hAlignment, vAlignment);
		},
		_createWithTTFConfig : function (ttfConfig, text, hAlignment=undefined, maxLineWidth=undefined) {
			ttfConfig.fontFilePath = LLFont.getFontNameWithFilepath(ttfConfig.fontFilePath);
			return new cc.LabelTTF(text, ttfConfig.fontFilePath, ttfConfig.fontSize, null, hAlignment);
		},
		////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		createWithBMFont : function (fntFile, str, alignment=undefined, width=undefined, imageOffset=undefined) {
			return new cc.LabelBMFont(str, fntFile, width, alignment, imageOffset)
		},
	};
	//*/

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	cc.Label.Overflow = {
		NONE: 0,
		CLAMP: 1,
		SHRINK: 2,
		RESIZE_HEIGHT: 3
	};
	cc.Label.LabelType = {
		TTF: 0,
		BMFONT: 1,
		CHARMAP: 2,
		STRING_TEXTURE: 3
	};

	(function(){
		cc.Label.LetterInfo = function (param) {
			//成员变量
			this.utf32Char = 0;//char32_t
			this.valid = false;
			this.positionX = 0.0;
			this.positionY = 0.0;
			this.atlasIndex = 0;
			this.lineIndex = 0;
		};
	})();
}